import { queryLawList } from '@/services/law';
import { queryVideos } from '@/services/video';

export default {
  namespace: 'law',

  state: {
    lawList: {},
    video: {},
  },

  effects: {
    *queryLawList({ payload }, { call, put }) {
      const response = yield call(queryLawList, payload.page_num, payload.page_size);
      yield put({
        type: 'setLawList',
        payload: {
          lawList: response ? response.data : [],
        },
      });
    },
    *queryVideo({ payload }, { call, put }) {
      const response = yield call(queryVideos, 23287, 1, 1);
      yield put({
        type: 'setLawList',
        payload: {
          video: response ? response.data : [],
        },
      });
    },
  },

  reducers: {
    setLawList(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },
  },
};
